package com.edu.bean;

import java.util.List;

public class Page<T> {
	private List<T> data;//查到的数据(查)
	
	private int pageNum;//当前页号
	
	private int pageSize;//页大小(一页最多装多少数据)
	
	private int totalRows;//总条数(查)
	
	private int totalPages;//总页数
	
	private boolean hasPrev;//有没有上一页
	
	private boolean hasNext;//有没有下一页
	
	private int userall;
	
	private int priceall;
	
	private int[] nagigatorNum;

	public int[] getNagigatorNum() {
		return nagigatorNum;
	}

	public void setNagigatorNum(int[] nagigatorNum) {
		this.nagigatorNum = nagigatorNum;
	}

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalRows() {
		return totalRows;
	}

	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public boolean isHasPrev() {
		return hasPrev;
	}

	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}

	public boolean isHasNext() {
		return hasNext;
	}

	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public int getUserall() {
		return userall;
	}

	public void setUserall(int userall) {
		this.userall = userall;
	}

	public int getPriceall() {
		return priceall;
	}

	public void setPriceall(int priceall) {
		this.priceall = priceall;
	}
	
	public Page() {
		
	}
	
	public Page(List<T> data, int pageNum, int pageSize, int totalRows, int userall, int priceall) {
		super();
		this.data = data;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalRows = totalRows;
		this.userall = userall;
		this.priceall = priceall;
	}

	public Page(List<T> data, int pageNum, int pageSize, int totalRows) {
		super();
		this.data = data;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalRows = totalRows;
		
		if(pageNum <= 1) {
			this.hasPrev=false;
		}else {
			this.hasPrev=true;
		}
		if(totalRows % pageSize ==0) {
			this.totalPages = totalRows / pageSize;
		}else {
			this.totalPages = (totalRows / pageSize)+1;
		}
		
		if(pageNum == this.totalPages ) {
			this.hasNext=false;
		}else {
			this.hasNext=true;
		}
				
		if(pageNum >10 ) {
			nagigatorNum=new int[10];
		}else {
			nagigatorNum=new int[totalPages];
		}
		if(pageNum<=5 || totalPages<10) {
			for(int i = 0;i<nagigatorNum.length;i++) {
				nagigatorNum[i] = i+1;
			}
		}else if(pageNum>5 && pageNum <= totalPages-5) {
			for(int i = 0,k = pageNum-4;i<nagigatorNum.length;i++,k++) {
				nagigatorNum[i] = k;
			}
		}else if(pageNum > totalPages-5) {
			for(int i = 0,k = totalPages-9;i<nagigatorNum.length;i++,k++) {
				nagigatorNum[i] = k;
			}
		}
	}
	
	
}
